import { createPinia } from 'pinia'
import persistedstate from 'pinia-plugin-persistedstate'

const pinia = createPinia()
pinia.use(persistedstate)

export default pinia

// 用户模块示例 (src/store/user.ts)
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    userInfo: {},
  }),
  actions: {
    setToken(token: string) {
      this.token = token
    },
  },
  persist: {
    key: 'user-store',
  },
})
